package com.sky.controller.user;

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/user/shop")
public class UserShopController {
    @Autowired
    private RedisTemplate redisTemplate;

    public static final String key = "SHOP_STATUS";

    /**
     * 获取营业状态
     */
    @GetMapping("/status")
    public Result<Integer>getShopStatus() {
        // 用 redis 获取营业状态
        Integer shopStatus = (Integer) redisTemplate.opsForValue().get(key);
        log.info("设置店铺状态为：{}", shopStatus == 1 ? "营业中" : "已打样");
        return Result.success(shopStatus);
    }
}
